## Figure A2: Clustering of Closing Dates by Day of Week and City

## install.packages(c("tidyverse"))
## library(tidyverse)

## SET WORKING DIRECTORY HERE
## setwd()

## Loading data
## load("dta.RData")

clustering_days_of_week = dta %>%
  filter(!is.na(close_day_of_week)) %>%
  mutate(n = 1,
         close_day_of_week = factor(close_day_of_week, levels = c("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"))) %>%
  group_by(city, close_day_of_week) %>%
  summarise(n_requests_closed = sum(n, na.rm = TRUE)) %>%
  ggplot(aes(x = factor(close_day_of_week), y = n_requests_closed)) +
  facet_wrap(city ~ ., scales = "free", ncol = 2) +
  geom_bar(stat = "identity", color="black", fill="gray") +
  labs(x = "Day of Week",
       y = "# of Requests Closed") +
  theme_classic()+
  theme(axis.text.x = element_text(angle = 45, hjust = 1),
        panel.grid.major = element_blank(), 
        panel.grid.minor = element_blank(),
        panel.background = element_rect(colour = "black"))